package base.test5.writableandpartition;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class    FlowMapper extends Mapper<LongWritable,Text, FlowBean,Text> {

    private FlowBean outK = new FlowBean();
    private Text outV = new Text();


    @Override
    protected void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException {

        //获取一行数据，转成字符串
        String line = value.toString();

        //分割数据
        String[] split = line.split("\t");

        //抓取需要的数据：手机号，上行流量，下行流量和总流量
        outV.set(split[0].toString());
        outK.setUpFlow(Long.parseLong(split[1]));
        outK.setDownFlow(Long.parseLong(split[2]));
        outK.setSumFlow(Long.parseLong(split[3]));


        //输出
        context.write(outK,outV);

    }
}
